﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0 user-scalable=yes">
    <link href="css/jquery.mobile-1.2.0.min.css" rel="stylesheet" type="text/css" />
    <link href="css/common.css" rel="stylesheet" />
    <script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.2.0.min.js" type="text/javascript"></script>
    <script src="js/phonegap.js"></script>
    <script src="js/config.js"></script>
    <script src="js/cookie.js"></script>
</head>
<body>
    <div data-role="page" id="a2">
        <div data-theme="b" data-role="header" class="ui-header ui-bar-a" role="banner" data-position="fixed" style="position: fixed; border-width: 0px 0px 1px;">
            <div id="btntest" style="height: 40px; line-height: 40px; vertical-align: middle; text-align: center;">摇一摇手机</div>
        </div>
        <div data-role="content">
            <div style="text-align: center; margin: 5px;">
                <a data-ajax="false" name="goto">
                    <img id="img1" /></a>
            </div>
            <div style="text-align: center; margin: 5px;">
                <a data-ajax="false" id="goto" name="goto"></a>
            </div>
        </div>
        <div data-role="footer" class="ui-footer ui-bar-a" role="contentinfo" data-position="fixed" style="position: fixed;">
            <div data-role="navbar" data-iconpos="top">
                <ul>
                    <li>
                        <a href="#" data-theme="b" data-icon="headerbtn6" class="ui-btn-active">每日推荐
                        </a>
                    </li>
                    <li>
                        <a url-value="list.html" href="list.html" data-theme="b" data-icon="headerbtn1" data-ajax="false">卖场
                        </a>
                    </li>
                    <li>
                        <a url-value="my.html" href="my.html" data-theme="b" data-icon="headerbtn2" data-ajax="false">我的
                        </a>
                    </li>
                    <li>
                        <a url-value="search.html" href="search.html" data-theme="b" data-icon="headerbtn3" data-ajax="false">搜索
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <script type="text/javascript" charset="utf-8">
        	$(document).bind('pageinit', function () {
        		getData();
        		$("#btntest").click(function(){
        			
        		});
        	});
        	
            $(function () {
                
            });

            var order = 2;
            var isReading = false;
            function getData() {
                if (order == 0) return;
                if (isReading) return;
                isReading = true;
                $.mobile.showPageLoadingMsg('b', "正在加载");
                $.ajax({
                    type: "get",
                    async: true,
                    url: apihost + "/index/iphone",
                    dataType: "json",
                    ceche: true,
                    data: { order: order, key: apikey },
                    jsonp: "data",//服务端用于接收callback调用的function名的参数
                    jsonpCallback: "success_jsonpCallback",//callback的function名称
                    success: function (json) {
                        try {
                            var data = json.data;
                            $("#img1").attr("src", data.bimg).attr("alt", data.title).attr("title", data.title);
                            $("#goto").html(data.title);
                            $("a[name='goto']").attr("href", "detail.html?id=" + data.id);
                            if (json.status == 0) {
                                order = 0;
                            } else {
                                order = json.order;
                            }
                        } catch (e) {
                        }
                        isReading = false;
                        $.mobile.hidePageLoadingMsg();
                    },
                    error: function () {
                        isReading = false;
                        $.mobile.hidePageLoadingMsg();
                    },
                    complete: function () {
                        isReading = false;
                        $.mobile.hidePageLoadingMsg();
                    }
                });
            }
        </script>
    </div>
</body>
</html>
